fix(mysql): repair caching_sha2_password fast-auth path#4245
Open
altmannmarcelo wants to merge 1 commit intolaunchbadge:mainfrom
Open
fix(mysql): repair caching_sha2_password fast-auth path#4245altmannmarcelo wants to merge 1 commit intolaunchbadge:mainfrom
altmannmarcelo wants to merge 1 commit intolaunchbadge:mainfrom
Conversation
The client-side scramble mixed the SHA-256 inputs in the wrong order, so no spec-compliant MySQL server could validate it. Every connection fell through to perform_full_authentication and the plugin's cache was never exercised. Two changes: 1. scramble_sha256 now hashes as SHA256(SHA256(SHA256(pw)) || nonce) to match the server's generate_sha2_scramble. Adds a unit test that simulates the server's XOR verification. 2. handle(..) returned true on fast_auth_success (0x01 0x03) without consuming the trailing OK_Packet, which then corrupted the next read. This was latent because 0x03 was never reached. It now yields back to the handshake loop so the OK is consumed by the existing 0x00 branch. fixes launchbadge#4244
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The client-side scramble mixed the SHA-256 inputs in the wrong order, so no spec-compliant MySQL server could validate it. Every connection fell through to perform_full_authentication and the plugin's cache was never exercised.
Two changes:
scramble_sha256 now hashes as SHA256(SHA256(SHA256(pw)) || nonce) to match the server's generate_sha2_scramble. Adds a unit test that simulates the server's XOR verification.
handle(..) returned true on fast_auth_success (0x01 0x03) without consuming the trailing OK_Packet, which then corrupted the next read. This was latent because 0x03 was never reached. It now yields back to the handshake loop so the OK is consumed by the existing 0x00 branch.
fixes #4244